package com.ktgj.hotel.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.hotel.domain.HotelNoticeway;
import com.ktgj.hotel.service.IHotelNoticewayService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 酒店通知渠道Controller
 * 
 * @author ruoyi
 * @date 2021-12-08
 */
@ControllerAdvice
@RestController
@RequestMapping("/noticeway")
public class HotelNoticewayController extends BaseController
{
    @Autowired
    private IHotelNoticewayService hotelNoticewayService;

    /**
     * 查询酒店通知渠道列表
     */
    @PreAuthorize(hasPermi = "hotel:noticeway:list")
    @GetMapping("/list")
    public TableDataInfo list(HotelNoticeway hotelNoticeway)
    {
        startPage();
        List<HotelNoticeway> list = hotelNoticewayService.selectHotelNoticewayList(hotelNoticeway);
        return getDataTable(list);
    }

    /**
     * 导出酒店通知渠道列表
     */
    @PreAuthorize(hasPermi = "hotel:noticeway:export")
    @Log(title = "酒店通知渠道", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotelNoticeway hotelNoticeway) throws IOException
    {
        List<HotelNoticeway> list = hotelNoticewayService.selectHotelNoticewayList(hotelNoticeway);
        ExcelUtil<HotelNoticeway> util = new ExcelUtil<HotelNoticeway>(HotelNoticeway.class);
        util.exportExcel(response, list, "酒店通知渠道数据");
    }

    /**
     * 获取酒店通知渠道详细信息
     */
    @PreAuthorize(hasPermi = "hotel:noticeway:query")
    @GetMapping(value = "/{noticewayid}")
    public AjaxResult getInfo(@PathVariable("noticewayid") Long noticewayid)
    {
        return AjaxResult.success(hotelNoticewayService.selectHotelNoticewayById(noticewayid));
    }

    /**
     * 新增酒店通知渠道
     */
    @PreAuthorize(hasPermi = "hotel:noticeway:add")
    @Log(title = "酒店通知渠道", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotelNoticeway hotelNoticeway)
    {
        return toAjax(hotelNoticewayService.insertHotelNoticeway(hotelNoticeway));
    }

    /**
     * 修改酒店通知渠道
     */
    @PreAuthorize(hasPermi = "hotel:noticeway:edit")
    @Log(title = "酒店通知渠道", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotelNoticeway hotelNoticeway)
    {
        return toAjax(hotelNoticewayService.updateHotelNoticeway(hotelNoticeway));
    }

    /**
     * 删除酒店通知渠道
     */
    @PreAuthorize(hasPermi = "hotel:noticeway:remove")
    @Log(title = "酒店通知渠道", businessType = BusinessType.DELETE)
	@DeleteMapping("/{noticewayids}")
    public AjaxResult remove(@PathVariable Long[] noticewayids)
    {
        return toAjax(hotelNoticewayService.deleteHotelNoticewayByIds(noticewayids));
    }
}
